
from datetime import datetime

from django.db import models


# Create your models here.

class BookCategory(models.Model):
    book_category = models.CharField(max_length=255,verbose_name="数据分类")
    category_code = models.IntegerField(verbose_name='分类码')
    CATRGORY_STATUS = (
        (0, "正常"),
        (1, '冻结'),
    )
    category_status = models.IntegerField(verbose_name="分类状态",choices=CATRGORY_STATUS)

    class Meta:
        verbose_name = "电子书分类"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.book_category

class Book(models.Model):
    """
       电子数
    """
    book_number = models.CharField(max_length=16, verbose_name="书籍编号",null=False)
    book_author = models.CharField(max_length=50, verbose_name="作者")
    book_category = models.CharField(max_length=50, verbose_name="分类")
    # models.ForeignKey(BookCategory, max_length=50, verbose_name="分类", on_delete=models.DO_NOTHING)
    book_details = models.TextField(default="", verbose_name="简介")
    book_finish_date = models.DateTimeField(default=datetime.now,verbose_name="完结时间")
    book_download_url = models.CharField(max_length=255,verbose_name="下载链接")
    book_img_url = models.CharField(max_length=255,verbose_name="图片链接")
    book_include_date = models.DateTimeField(default=datetime.now, verbose_name="包含时间")
    book_name = models.CharField(max_length=50,verbose_name="书名")
    book_origin = models.CharField(max_length=255,verbose_name="来源")
    book_size = models.CharField(max_length=20,verbose_name="大小kb")
    book_start_date = models.DateTimeField(default=datetime.now, verbose_name="开始时间")
    BOOK_STATUS = (
        ('1', '状态0'),
        ('2', '状态1'),
        ('3', '状态2'),
        ('4', '状态-1'),
    )
    book_status = models.CharField(max_length=1,verbose_name="状态", choices=BOOK_STATUS)
    book_download_times = models.CharField(max_length=10,verbose_name="下载次数")
    last_chapter = models.CharField(max_length=255,verbose_name="最新章节")
    keywords = models.CharField(max_length=255,verbose_name="关键词")
    chapters = models.SmallIntegerField(verbose_name="chapters")
    initial = models.CharField(max_length=1,verbose_name='首字母')
    book_update_date = models.DateTimeField(default=datetime.now, verbose_name="更新时间")


    class Meta:
        verbose_name = "电子书"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.book_name











